﻿using System;
using System.Collections.Generic;
using System.Text;

namespace SICOMModbus
{
    public class ModbusTCPMBAP
    {
        byte transactionIDFrist;
        /// <summary>
        /// 事务处理标识符第一字节
        /// </summary>
        public byte TransactionIDFrist
        {
            get { return transactionIDFrist; }
            set { transactionIDFrist = value; }
        }
        byte transactionIDSecond;
        /// <summary>
        /// 事务处理标识符第二字节
        /// </summary>
        public byte TransactionIDSecond
        {
            get { return transactionIDSecond; }
            set { transactionIDSecond = value; }
        }
        byte protocolIDFrist = 0;

        /// <summary>
        /// 协议标识符第一字节（Modbus为0）
        /// </summary>
        public byte ProtocolIDFrist
        {
            get { return protocolIDFrist; }
            set { protocolIDFrist = value; }
         
        }
        byte protocolIDSecond=0;
        /// <summary>
        /// 协议标识符第二字节（Modbus为0）
        /// </summary>
        public byte ProtocolIDSecond
        {
            get { return protocolIDSecond; }
            set { protocolIDSecond = value; }
        }
        byte lengthFrist;
        /// <summary>
        /// 命令长度第一字节
        /// </summary>
        public byte LengthFrist
        {
            get { return lengthFrist; }
            set { lengthFrist = value; }
        }

        byte lengthSecond;
        /// <summary>
        /// 命令长度第二字节
        /// </summary>
        public byte LengthSecond
        {
            get { return lengthSecond; }
            set { lengthSecond = value; }
        }

        byte netID;
        /// <summary>
        /// 单元标识符
        /// </summary>
        public byte NetID
        {
            get { return netID; }
            set { netID = value; }
        }

        public byte[] getBytes()
        {
            return new byte[] { transactionIDFrist ,
                transactionIDSecond,
                protocolIDFrist,
                protocolIDSecond,
                lengthFrist,
                lengthSecond,
                netID
            };
        }
    }
}
